/*  1:   */ package org.jeecgframework.poi.excel.view;
/*  2:   */ 
/*  3:   */ import java.net.URLEncoder;
/*  4:   */ import java.util.Map;
/*  5:   */ import javax.servlet.ServletOutputStream;
/*  6:   */ import javax.servlet.http.HttpServletRequest;
/*  7:   */ import javax.servlet.http.HttpServletResponse;
/*  8:   */ import org.apache.poi.xwpf.usermodel.XWPFDocument;
/*  9:   */ import org.jeecgframework.poi.word.WordExportUtil;
/* 10:   */ import org.springframework.stereotype.Controller;
/* 11:   */ import org.springframework.web.servlet.view.AbstractView;
/* 12:   */ 
/* 13:   */ @Controller("jeecgTemplateWordView")
/* 14:   */ public class JeecgTemplateWordView
/* 15:   */   extends AbstractView
/* 16:   */ {
/* 17:   */   private static final String CONTENT_TYPE = "application/msword";
/* 18:   */   
/* 19:   */   public JeecgTemplateWordView()
/* 20:   */   {
/* 21:43 */     setContentType("application/msword");
/* 22:   */   }
/* 23:   */   
/* 24:   */   public boolean isIE(HttpServletRequest request)
/* 25:   */   {
/* 26:47 */     return (request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0) || (request.getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0);
/* 27:   */   }
/* 28:   */   
/* 29:   */   protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
/* 30:   */     throws Exception
/* 31:   */   {
/* 32:54 */     String codedFileName = "临时文件.docx";
/* 33:55 */     if (model.containsKey("fileName")) {
/* 34:56 */       codedFileName = (String)model.get("fileName") + ".docx";
/* 35:   */     }
/* 36:58 */     if (isIE(request)) {
/* 37:59 */       codedFileName = URLEncoder.encode(codedFileName, "UTF8");
/* 38:   */     } else {
/* 39:61 */       codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
/* 40:   */     }
/* 41:63 */     response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
/* 42:64 */     XWPFDocument document = WordExportUtil.exportWord07((String)model.get("url"), (Map)model.get("map"));
/* 43:   */     
/* 44:   */ 
/* 45:67 */     ServletOutputStream out = response.getOutputStream();
/* 46:68 */     document.write(out);
/* 47:69 */     out.flush();
/* 48:   */   }
/* 49:   */ }


/* Location:           C:\Users\Administrator\.m2\repository\org\jeecgframework\easypoi-web\2.1.4\easypoi-web-2.1.4\
 * Qualified Name:     org.jeecgframework.poi.excel.view.JeecgTemplateWordView
 * JD-Core Version:    0.7.0.1
 */